using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using kxcxw.Data.Entities;

namespace kxcxw.Data.Mapping
{
	public class PublichInformationMap : EntityTypeConfiguration<PublichInformation>
	{
		public PublichInformationMap()
		{
			// Primary Key
			this.HasKey(t => t.InformationID);

			// Properties
			this.Property(t => t.InformationID)
				.IsRequired()
				.HasMaxLength(36);
				
			this.Property(t => t.Title)
				.HasMaxLength(400);
            this.Property(t => t.Brand)
                .HasMaxLength(50);
				
			this.Property(t => t.ItemDeitalID)
				.HasMaxLength(36);

            this.Property(t => t.PromotionType)
                .HasMaxLength(36);
				
			this.Property(t => t.MapUrl)
				.HasMaxLength(200);

            this.Property(t => t.ShopUrl)
                .HasMaxLength(1000);
				
			this.Property(t => t.Other)
				.HasMaxLength(200);

			this.Property(t => t.Addres)
				.HasMaxLength(200);
				
			this.Property(t => t.Mobile)
				.HasMaxLength(20);
				
			this.Property(t => t.ContactPerson)
				.HasMaxLength(36);
				
			this.Property(t => t.IM)
				.HasMaxLength(20);
				
			this.Property(t => t.InfoSource)
				.HasMaxLength(36);
				
			this.Property(t => t.PublishID)
				.HasMaxLength(36);
				
			// Table & Column Mappings
			this.ToTable("PublichInformation");
			this.Property(t => t.InformationID).HasColumnName("InformationID");
			this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.Brand).HasColumnName("Brand");
			this.Property(t => t.ItemDeitalID).HasColumnName("ItemDeitalID");
			this.Property(t => t.MapUrl).HasColumnName("MapUrl");
			this.Property(t => t.OriginalPrice).HasColumnName("OriginalPrice");
			this.Property(t => t.Discount).HasColumnName("Discount");
			this.Property(t => t.PresentPrice).HasColumnName("PresentPrice");
			this.Property(t => t.Other).HasColumnName("Other");
			this.Property(t => t.StartDate).HasColumnName("StartDate");
			this.Property(t => t.EndDate).HasColumnName("EndDate");
            this.Property(t => t.Desception).HasColumnName("Desception");
			this.Property(t => t.Addres).HasColumnName("Addres");
			this.Property(t => t.Mobile).HasColumnName("Mobile");
			this.Property(t => t.ContactPerson).HasColumnName("ContactPerson");
			this.Property(t => t.IM).HasColumnName("IM");
			this.Property(t => t.PictureShow).HasColumnName("PictureShow");
			this.Property(t => t.InfoSource).HasColumnName("InfoSource");
			this.Property(t => t.PriorityLevel).HasColumnName("PriorityLevel");
			this.Property(t => t.InfoType).HasColumnName("InfoType");
			this.Property(t => t.PublishID).HasColumnName("PublishID");
			this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.VisitsNumber).HasColumnName("VisitsNumber");
			this.Property(t => t.PublishDate).HasColumnName("PublishDate");

			// Relationships
			this.HasOptional(t => t.SysItemDetial)
				.WithMany(t => t.PublichInformations)
				.HasForeignKey(d => d.ItemDeitalID);
				
			this.HasOptional(t => t.SysUserInfo)
				.WithMany(t => t.PublichInformations)
				.HasForeignKey(d => d.PublishID);
				
		}
	}
}

